<?php
	$path_one = 'admin/admin_system';
	$path_two = 'admin/admin_module';
	$filename = 'admin/admin_admin_list';
	require_once("header.php");
	require_once("admin_comm.php");
	
	$boss_object=new boss();
	$id= request('id',false,true);
	$info=$boss_object->_car_info($id);
	if(!$info)return false;	
		
	$cond['carid']=$id;
	$result=$boss_object->cash_search($cond);		
	if($result['rows'][0]){
		$first=$result['rows'][0];
	}
	
	$binfo=$boss_object->admin_boss_info($info['uid']);	
?>
<script type="text/javascript" charset="utf-8">
	loader.file({
		plugin:['validform/main','dialog/main'],
		js:['city_area', 'html'],
		skincss:['list']
	});
	$(document).ready(function(){
		var form_obj=$("#form1").Validform({
		   tiptype: function(msg, o, cssctl){
			   if(!o.obj.is("form")){
				   var obj = o.obj.parent("td").find('tt');
				   cssctl(obj, o.type);
				   obj.text(msg);
			   }
		   },
		   postonce:true
		})
	})
	
	function dopost(){
       if(!confirm('确认设备已充值？'))return false;
       $("#form1").submit();  
	}	
</script>
</head>
<body>
	<div class="position_nav">你所在的当前位置：<?php echo $path_str;?> &gt; 充值</div>
		<div class="main">
		
		<table cellpadding="0" cellspacing="1" border="0" class="table" style="width:98%;">
			
			<tr>
			    <td>老板姓名</td>
				<td style="text-align: left">
					<strong><?php echo $binfo['name']?></strong>
				</td>
			    <td>联系电话</td>			
				<td style="text-align: left">
					<?php echo $binfo['phone'];?>
				</td>			
			</tr>
			
			<tr>
			    <td>车型</td>			
				<td style="text-align: left">
				<?php echo $info['car']?>
			     </td>				
			    <td>车牌号</td>			
				<td style="text-align: left">
				    <?php echo $info['carno']?>
			    </td>
			</tr>				
			
			<tr>
			    <td>车手</td>			
				<td style="text-align: left">
					<?php echo $info['linkman']?>
				</td>
			    <td>车手电话</td>			
				<td style="text-align: left">
				    <?php echo $info['phone']?>
				</td>								
			</tr>	
			
			<tr>
			    <td>绑定设备</td>			
				<td style="text-align: left">
					<?php echo $info['code']?>
				</td>
			    <td>绑定时间</td>			
				<td style="text-align: left">
				    <?php echo date('Y-m-d H:i:s',$info['bindtime']);?>
				</td>								
			</tr>	
			
			<?php 
			  if($info['code']){
			?>
			<tr>
			    <td>到期时间</td>			
				<td colspan=3 style="text-align: left">												
				    <?php echo date('Y-m-d H:i:s',$info['endtime']);?>
				    <?php
				      if($info['endtime']<time()){ 
				    ?>
				    <font color="red">已到期</font>
				    <?php 
				      }
				    ?>
				</td>								
			</tr>				
			<?php
              }
			?>
						
			<tr>
			    <td>审核状态</td>			
				<td colspan=3 style="text-align: left">
					<?php echo 1==$info['state']?"启用":"<font color='red'>禁用</font>"; ?>&nbsp;
					<?php 
					  if(1==$info['state']){
					?>
					<a href="/handle.php?h=boss/admin_carstate&id=<?php echo $info['id']?>&state=0">点击禁用</a>
					<?php
                      }else{
					?>
					<a href="/handle.php?h=boss/admin_carstate&id=<?php echo $info['id']?>&state=1">点击启用</a>
					<?php } ?>
				</td>			    								
			</tr>							
		
		</table>  		
		
		<?php 
		  if($first && $first['state']==0){
		?>
			<form action="/handle.php" method="post" id='form1'>
			<input type="hidden" name="h" value="boss/boss_cashdeal">
			<input type="hidden" name="id" value="<?php echo $first['id']?>">
			<table  cellpadding="0" cellspacing="1" border="0" class="table table_text" style="margin-top:20px;">		
				<tr>
					<td colspan="2"><h2>充值：</h2></td>		
				</tr>					
				<tr>
					<td class="left">充值金额：</td>
					<td><?php echo $first['money'];?></td>
				</tr>
				<tr>
					<td class="left">延长时长：</td>
					<td><?php echo $first['length']/86400;?>天</td>
				</tr>
				<tr>
					<td class="left">申请时间：</td>
					<td><?php echo date('Y-m-d H:i:s',$first['time']);?></td>
				</tr>				
				<tr>
					<td class="left">备注信息：</td>
					<td>
						<textarea name="comment"></textarea>
						<tt></tt>
					</td>
				</tr>				
				<tr>
					<td></td>
					<td>
						<input class="button1" type="button" onclick="dopost();" value="确认充值">
						<a href="/handle.php?h=boss/boss_cashdel&id=<?php echo $first['id'];?>" onclick="javascript:return confirm('确认删除该充值申请?');">删除申请</a>
					</td>
				</tr>

			</table>
			</form>
			<?php 
			}else{
               $rtn=cash_menu(2);
			?>
			<form action="/handle.php" method="post" id='form1'>
			<input type="hidden" name="h" value="boss/boss_cashadd">
			<input type="hidden" name="id" value="<?php echo $id;?>">
			<table  cellpadding="0" cellspacing="1" border="0" class="table table_text" style="margin-top:20px;">		
				<tr>
					<td colspan="2"><h2>充值：</h2></td>		
				</tr>					
				<tr>
					<td class="left">选择套餐：</td>
					<td>
					   <select name="pid">
					     <?php 
					        if($rtn){
                             foreach($rtn as $key=>$val){
					     ?>
					     <option value="<?php echo $key;?>"><?php echo $val['title'];?></option>
					     <?php 
					       }}
					     ?>
					   </select>
					</td>
				</tr>			
				<tr>
					<td class="left">备注信息：</td>
					<td>
						<textarea name="comment"></textarea>
						<tt></tt>
					</td>
				</tr>				
				<tr>
					<td></td>
					<td>
						<input class="button1" type="button" onclick="dopost();" value="确认充值">						
					</td>
				</tr>

			</table>
			</form>			
			<?php 
			  }
			?>
			
			<?php 
			if($result['rows']){
			?>
			<table  cellpadding="0" cellspacing="1" border="0" class="table table_text" style="margin-top:20px;">
				<tr>
					<td colspan="5"><h2>充值日志：</h2></td>					
				</tr>
				<tr>
					<th align="left">时间</th>					
					<th align="left">金额</th>
					<th align="left">延长时长</th>
					<th align="left">状态</th>
					<th align="left">备注</th>											
				</tr>				
				<?php 
                    foreach($result['rows'] as $val){
				?>
				<tr>				   
					<td><?php echo date('Y-m-d H:i',$val['time']);?></td>
					<td>
						<?php echo $val['money'];?>
					</td>
					<td>
						<?php echo $val['length']/86400;?>天
					</td>
					<td><?php echo 1==$val['state']?'已处理':'<font color="red">待处理</font>';?></td>
					<td>
						<?php echo $val['comment'];?>
					</td>										
				</tr>				
				<?php 
				}
				?>		
			</table>	
			<?php 
			}
			?>		
			
		</div>
	</div>
</body>
</html>



